package com.fz.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.List;
import java.util.UUID;

/**
 * Created by webrx on 2017/7/10.
 */
@Controller @RequestMapping("/sell")
public class Fuzhuang_add {

    @RequestMapping("/fuzhuangadd")
   public  String fuzhuangadd(){
       return "sell/fuzhangadd";
   }


   @RequestMapping("/fuzhuangadd02")
   public void fuzhuangadd02(HttpServletRequest req, HttpServletResponse resp, @RequestParam("file")List<CommonsMultipartFile> fs){
       resp.setContentType("text/html;charset=utf-8");
       resp.setCharacterEncoding("utf-8");
       String account =req.getParameter("account");
       String price =req.getParameter("price");
       String pname =req.getParameter("pname");
       String content =req.getParameter("content");
       System.out.println(content);
       System.out.println(account);

       String path =req.getServletContext().getRealPath("/upload/fuzhuang/");
       File fi = new File(path);
       if(!fi.exists()){
           fi.mkdir();
       }
       for(CommonsMultipartFile info : fs){

           String name01 = info.getOriginalFilename();
          String txt= name01.substring(name01.lastIndexOf("."));
          String nameall = UUID.randomUUID()+txt;
           System.out.println(nameall);

       }
   }
}
